package com.framework.base.util;

import org.springframework.context.ApplicationContext;

import com.framework.base.dao.BaseDao;
import com.framework.base.service.BaseService;
import com.framework.main.sys.attachment.service.AttachmentService;

/**
 * @Copyright @ 2011 All right reserved
 * @version 创建时间：Created on 2011-3-11
 * @author 作者：Create by HYH
 * @Email: 517372264@qq.com
 * @description 用于获取spring bean对象
 * 
 */
public class BeanUtil {
	public  static  ApplicationContext ctx;

	/**
	 * 用于获取业务处理对象 即service层的bean对象
	 * @param beanId
	 * @return
	 */
	public static BaseService getServiceBeanById(String beanId) {
		return (BaseService)ctx.getBean(beanId);
	}
	/**
	 * 从spring获取附件业务的service
	 * @return
	 */
	public static AttachmentService getAttachmentService(){
		return (AttachmentService) getServiceBeanById("AttachmentService");
	}
	
	
	public static BaseDao getDaoBeanById(String beanId) {
		return (BaseDao)ctx.getBean(beanId);
	}
	
	public static Object getObjectBeanById(String beanId){
		return ctx.getBean(beanId);
	}
	
}
